
/*
	new iEnt = EntitySkillCreate( .iPlayer = id,
								.fThinkTime = 0.0,
								.fDmgTime = 0.0,
								.fKillTime = 0.0,
								.iDamage = 0,
								.fRadius = 0.0,
								.iProperty = SEP_THINK|SEP_TOUCH|SEP_DAMAGE|SEP_AOEDAMAGE|SEP_KILL,
								.iMoveType = MOVETYPE_,
								.iSolidType = SOLID_,
								.iModel = MODEL_,
								.iSound = SOUND_,
								.iSprite = SPRITE_,
								.vOrigin = vOrigin,
								.bPlayerOrigin = false,
								.vAngles = vAngles,
								.bPlayerAngles = false,
								.vMins = Float:{-1.0,-1.0,-1.0},
								.vMaxs = Float:{1.0,1.0,1.0},
								.vVelocity = vVelocity,
								.iAimVelocity = StatClamp( id, STAT_SPEED, 100, 1000 )
								);
*/
PM_FUNC_NORM_ATTRIB EntitySkillCreate( Int:iPlayer,
					SKILLENT_PROP:iProperty,
					Float:fThinkTime = 0.0,
					Float:fDmgTime = 0.0,
					Float:fKillTime = 0.0,
					Int:iDamage = 0,
					Float:fRadius = 0.0,
					Int:iMoveType = MOVETYPE_NONE,
					Int:iSolidType = SOLID_NOT,
					POKE_MODELS:iModel = MODEL_NONE,
					POKE_SOUNDS:iSound = SOUND_NONE,
					POKE_SPRITES:iSprite = SPRITE_NONE,
					Vector:vOrigin[3] = {0.0,0.0,0.0},
					bool:bPlayerOrigin = false,
					Vector:vAngles[3] = {0.0,0.0,0.0},
					bool:bPlayerAngles = false,
					Vector:vMins[3] = {-1.0,-1.0,-1.0},
					Vector:vMaxs[3] = {1.0,1.0,1.0},
					Vector:vVelocity[3] = {0.0,0.0,0.0},
					Int:iAimVelocity = 0
				)
{
	pokemod_funcstart_debug( "EntitySkillCreate %s", SkillToName( g_iSkillID ) );

	new Int:iEnt = EntityCreate();
	set_pev( iEnt, pev_classname, szEntityPokeSkill );

	if ( fDmgTime > 0.0 )
	{
		if ( fThinkTime <= 0.0 || fThinkTime > fDmgTime )
		{
			fThinkTime = fDmgTime;
		}
	}
	if ( fKillTime > 0.0 )
	{
		if ( fThinkTime <= 0.0 || fThinkTime > fKillTime )
		{
			fThinkTime = fKillTime;
		}
		iProperty |= SEP_KILL;
	}
	if ( fThinkTime > 0.0 )
	{
		iProperty |= SEP_THINK;

		new Float:fGameTime = get_gametime();

		EntitySetFloat( iEnt, ENTITY_THINKTIME, fThinkTime );
		set_pev( iEnt, pev_nextthink, fGameTime + 0.01 );

		if ( fDmgTime > 0.0 )
		{
			EntitySetFloat( iEnt, ENTITY_DAMAGETIME, fDmgTime );
			EntitySetFloat( iEnt, ENTITY_NEXTDAMAGETIME, fGameTime + fDmgTime );
		}

		if ( fKillTime > 0.0 )
			EntitySetFloat( iEnt, ENTITY_KILLTIME, fGameTime + fKillTime );
	}
	if ( iDamage )
	{
		EntitySetNum( iEnt, ENTITY_DAMAGE, iDamage );
		if ( fRadius > 0.0 )
		{
			EntitySetFloat( iEnt, ENTITY_RADIUS, fRadius );
			iProperty |= SEP_AOEDAMAGE;
		}
		else
			iProperty |= SEP_DAMAGE;
	}

	EntitySetNum( iEnt, ENTITY_PROPERTIES, iProperty );
	EntitySetNum( iEnt, ENTITY_OWNER, iPlayer );
	EntitySetNum( iEnt, ENTITY_SKILL, _:g_iSkillID );
	EntitySetNum( iEnt, ENTITY_SKILLNUM, g_iSkillNum );

	EntitySetMoveType( iEnt, iMoveType );
	EntitySetSolid( iEnt, iSolidType );

	if ( iModel == MODEL_NONE )
	{
		EntitySetModel( iEnt, MODEL_POKEBALL );
		//Make it invisible
		fm_set_rendering( iEnt, kRenderFxGlowShell, 0, 0, 0, kRenderTransAlpha, 0 );
	}
	else
	{
		EntitySetModel( iEnt, iModel );
	}

	EntitySetNum( iEnt, ENTITY_SOUND, iSound );
	EntitySetNum( iEnt, ENTITY_SPRITE, iSprite );

	if ( bPlayerAngles )
	{
		new Vector:vPlayerAngles[3];
		EntityGetAngles( iPlayer, vPlayerAngles );
		xs_vec_add( vAngles, vPlayerAngles, vAngles );
	}
	if ( vector_length( vAngles ) > 0.0 )
		EntitySetAngles( iEnt, vAngles );

	if ( bPlayerOrigin )
	{
		new Vector:vPlayerOrigin[3];
		EntityGetOrigin( iPlayer, vPlayerOrigin );
		xs_vec_add( vOrigin, vPlayerOrigin, vOrigin );
	}
	if ( vector_length( vOrigin ) > 0.0 )
		EntitySetOrigin( iEnt, vOrigin );

	if ( vector_length( vMins ) > 0.0 || vector_length( vMaxs ) > 0.0 )
		EntitySetSize( iEnt, vMins, vMaxs );

	if ( iPlayer && iAimVelocity )
	{
		new Vector:vAimVelocity[3];
		velocity_by_aim( iPlayer, iAimVelocity, vAimVelocity );
		xs_vec_add( vVelocity, vAimVelocity, vVelocity );
	}
	if ( vector_length( vVelocity ) > 0.0 )
		EntitySetVelocity( iEnt, vVelocity );

	pokemod_funcend_debug( "EntitySkillCreate" );

	return iEnt;
}

PM_FUNC_NORM_ATTRIB EntitySetNum( Int:iEnt, ENTITY_PROPS:iProp, any:iNum )
{
	if ( iProp >= ENTITY_FLOATS )
		set_pev( iEnt, EntityProp[iProp], float(iNum) );
	else
		set_pev( iEnt, EntityProp[iProp], iNum );
}
PM_FUNC_NORM_ATTRIB EntityGetNum( Int:iEnt, ENTITY_PROPS:iProp )
{
	if ( iProp >= ENTITY_FLOATS )
	{
		new Float:fNum;
		pev( iEnt, EntityProp[iProp], fNum );
		return floatround( fNum );
	}
	return pev( iEnt, EntityProp[iProp] );
}

PM_FUNC_NORM_ATTRIB EntitySetFloat( Int:iEnt, ENTITY_PROPS:iProp, Float:fNum )
{
	if ( iProp < ENTITY_FLOATS )
		set_pev( iEnt, EntityProp[iProp], floatround( fNum ) );
	else
		set_pev( iEnt, EntityProp[iProp], fNum );
}
PM_FUNC_NORM_ATTRIB Float:EntityGetFloat( Int:iEnt, ENTITY_PROPS:iProp )
{
	if ( iProp < ENTITY_FLOATS )
		return float( pev( iEnt, EntityProp[iProp] ) );
	new Float:fNum;
	pev( iEnt, EntityProp[iProp], fNum );
	return fNum;
}

PM_FUNC_NORM_ATTRIB EntitySoundEmit( Int:iEnt, POKE_SOUNDS:iSound )
{
	EntitySetNum( iEnt, ENTITY_PLAYSOUND, iSound );
	emit_sound( iEnt, CHAN_VOICE, gSounds[ iSound ], VOL_NORM, ATTN_NORM, 0, PITCH_NORM );
}
PM_FUNC_NORM_ATTRIB EntitySoundStop( Int:iEnt )
{
	new POKE_SOUNDS:iSound = POKE_SOUNDS:EntityGetNum( iEnt, ENTITY_PLAYSOUND );
	emit_sound( iEnt, CHAN_VOICE, gSounds[ iSound ], VOL_NORM, ATTN_NORM, SND_STOP, PITCH_NORM );
}

PM_FUNC_NORM_ATTRIB EntityKill( Int:iEnt )
{
	set_pev( iEnt, pev_flags, pev( iEnt, pev_flags ) | FL_KILLME );
}

PM_FUNC_NORM_ATTRIB EntityOak( Int:iTeam )
{
	new Int:iEntity = create_entity( szEntityHostage );

	EntitySetModel( iEntity, MODEL_OAK );
//	EntitySetMoveType( iEntity, MOVETYPE_TOSS );
	EntitySetSolid( iEntity, SOLID_SLIDEBOX );
	EntitySetMoveType( iEntity, MOVETYPE_STEP );

//	set_pev( iEntity, pev_flags, pev( iEntity, pev_flags ) | FL_MONSTER );

	set_pev( iEntity, pev_controller_0, 125 );
	set_pev( iEntity, pev_controller_1, 125 );
	set_pev( iEntity, pev_controller_2, 125 );
	set_pev( iEntity, pev_controller_3, 125 );

	entity_set_size( iEntity, Float:{-16.0,-16.0,-40.0},Float:{16.0,16.0,40.0} );

	new Float:fOakHealth = SettingGetFloat( OAK_HEALTH );
	set_pev( iEntity, pev_health, fOakHealth );
	set_pev( iEntity, pev_max_health, fOakHealth );

	if ( fOakHealth > 0.0 )
	{
		set_pev( iEntity, pev_takedamage, DAMAGE_AIM );
	}
	else
	{
		set_pev( iEntity, pev_takedamage, DAMAGE_NO );
	}

	set_pev( iEntity, pev_deadflag, DEAD_NO );

	set_pev( iEntity, pev_skin, iTeam - 1 );

	set_pev( iEntity, pev_animtime, 2.0 );
	set_pev( iEntity, pev_framerate, 1.0 );

	cs_set_hostage_foll( iEntity );
	cs_set_hostage_nextuse( iEntity, 0.0 );

	dllfunc( DLLFunc_Spawn, iEntity );

	set_pev( iEntity, pev_classname, szEntityPokeOak );
	set_pev( iEntity, pev_team, iTeam );

	new String:szSpawnEntClass[ 32 ];
	copy( szSpawnEntClass, charsmax(szSpawnEntClass), iTeam == 2 ? "info_player_start" : "info_player_deathmatch" );

	new Int:iSpawnEntity, Int:iEntList[ 1 ];
	new Array:iSpawnEnts = ArrayCreate(1,1);
	while ( ( iSpawnEntity = engfunc( EngFunc_FindEntityByString, iSpawnEntity, "classname", szSpawnEntClass ) ) )
	{
		if ( !find_sphere_class( iSpawnEntity, szEntityPlayer, .radius = 32.0, .entlist = iEntList, .maxents = sizeof iEntList ) )
			ArrayPushCell( iSpawnEnts, iSpawnEntity );
	}

	new Int:iSize = ArraySize( iSpawnEnts );
	if ( iSize <= 0 )
	{
		ArrayDestroy( iSpawnEnts );
		EntityKill( iEntity );
		return;
	}

	iSpawnEntity = ArrayGetCell( iSpawnEnts, random( iSize ) );
	ArrayDestroy( iSpawnEnts );

	new Vector:vOrigin[3], Vector:vAngles[3];
	EntityGetOrigin( iSpawnEntity, vOrigin );
	EntityGetAngles( iSpawnEntity, vAngles );

	EntitySetOrigin( iEntity, vOrigin );
	EntitySetAngles( iEntity, vAngles );

	set_pev( iEntity, pev_v_angle, vAngles );
	set_pev( iEntity, pev_sequence, random_num( 0, 2 ) );

	entity_set_size( iEntity, Float:{-16.0,-16.0,-40.0},Float:{16.0,16.0,40.0} );

	drop_to_floor( iEntity );
}




